package cn.cvs.service.sysRole;

import cn.cvs.pojo.SysRole;
import org.apache.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.Date;
import java.util.List;

public class SysRoleTest {
    private Logger logger = Logger.getLogger(SysRoleTest.class);

    @Before
    public void setUp() throws Exception {
    }

    @Test
    public void selectRoleNameList() {
        String[] configs = {"applicationContext.xml", "applicationContext-dao.xml", "applicationContext-service.xml"};
        ApplicationContext ctx = new ClassPathXmlApplicationContext(configs);
        SysRoleService sysRoleService = (SysRoleService) ctx.getBean("sysRoleService");
        SysRole sysRole = new SysRole();
        sysRole.setRoleName("店");
        List<SysRole> list = sysRoleService.selectRoleNameList(sysRole);

        for (SysRole userResult : list) {
            logger.debug(userResult.getId() + "\t" + userResult.getCode() + "\t" + userResult.getRoleName());
        }
    }

    @Test
    public void testAdd() {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        SysRoleService sysRoleService = (SysRoleService) applicationContext.getBean("sysRoleService");
        SysRole sysRole = new SysRole();
        sysRole.setCode("SMBMS_EMPLOYEE");
        sysRole.setRoleName("ZZZ");
        sysRole.setCreatedUserId(1);
        sysRole.setCreatedTime(new Date());
        int result = sysRoleService.add(sysRole);
        logger.debug("testAdd:"+result);

    }
}